import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  // base: '/camera/',
  plugins: [
    vue(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    host: '0.0.0.0', //ip地址
    port: 8012, //端口号
    open: false, //启动后是否自动打开浏览器
    hmr: {
      overlay: true
    },
    proxy: {
      '/hsq': {
        target: 'http://111.198.11.2:10051/',
        changeOrigin: true,
        secure: true,
        rewrite: (path) => path.replace(/^\/hsq/, '')
      },
      '/api': {
        target: 'http://111.198.11.2:10051/',
        changeOrigin: true,
        secure: true,
        rewrite: (path) => path.replace(/^\//, '')
      },
    }
  }
})
